home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 23 / AMIGAplus Sonderheft 23 (2000)(Falke)(DE)[!].iso / Updates / HD-Installer / -WHDLoad- / WHDLoad_dev / Include / whdload.i
Text File  |  1999-11-08  |  16KB  |  563 lines

  1.  
  2.  IFND WHDLOAD_I
  3. WHDLOAD=1
  4.  
  5.     IFND    EXEC_EXECBASE_I
  6.     INCLUDE    exec/execbase.i
  7.     ENDC
  8.     IFND    EXEC_TYPES_I
  9.     INCLUDE    exec/types.i
  10.     ENDC
  11.     IFND    GRAPHICS_MODEID_I
  12.     INCLUDE    graphics/modeid.i
  13.     ENDC
  14.     IFND    HARDWARE_CIA_I
  15.     INCLUDE    hardware/cia.i
  16.     ENDC
  17.     IFND    HARDWARE_CUSTOM_I
  18.     INCLUDE    hardware/custom.i
  19.     ENDC
  20.     IFND    HARDWARE_INTBITS_I
  21.     INCLUDE    hardware/intbits.i
  22.     ENDC
  23.     IFND    HARDWARE_DMABITS_I
  24.     INCLUDE    hardware/dmabits.i
  25.     ENDC
  26.     IFND    UTILITY_TAGITEM_I
  27.     INCLUDE    utility/tagitem.i
  28.     ENDC
  29.  
  30. ;some custom stuff
  31.  
  32.  BITDEF POTGO,OUTRY,15
  33.  BITDEF POTGO,DATRY,14
  34.  BITDEF POTGO,OUTRX,13
  35.  BITDEF POTGO,DATRX,12
  36.  BITDEF POTGO,OUTLY,11
  37.  BITDEF POTGO,DATLY,10
  38.  BITDEF POTGO,OUTLX,9
  39.  BITDEF POTGO,DATLX,8
  40.  BITDEF POTGO,START,0
  41.  
  42. _ciaa        = $bfe001
  43. _ciab        = $bfd000
  44. _custom        = $dff000
  45.  
  46. ;=============================================================================
  47. ;    misc
  48. ;=============================================================================
  49.  
  50. SLAVE_HEADER    MACRO
  51.         moveq    #-1,d0
  52.         rts
  53.         dc.b    "WHDLOADS"
  54.         ENDM
  55.  
  56. ;=============================================================================
  57. ;    some useful macros
  58. ;=============================================================================
  59.  
  60. ****************************************************************
  61. ***** write opcode ILLEGAL to specified address
  62. ill    MACRO
  63.     IFNE    NARG-1
  64.         FAIL    arguments "ill"
  65.     ENDC
  66.         move.w    #$4afc,\1
  67.     ENDM
  68.  
  69. ****************************************************************
  70. ***** write opcode RTS to specified address
  71. ret    MACRO
  72.     IFNE    NARG-1
  73.         FAIL    arguments "ret"
  74.     ENDC
  75.         move.w    #$4e75,\1
  76.     ENDM
  77.  
  78. ****************************************************************
  79. ***** skip \1 instruction bytes on address \2
  80. skip    MACRO
  81.     IFNE    NARG-2
  82.         FAIL    arguments "skip"
  83.     ENDC
  84.     IFLE \1-126
  85.         move.w    #$6000+\1-2,\2
  86.     ELSE
  87.     IFLE \1-32766
  88.         move.l    #$60000000+\1-2,\2
  89.     ELSE
  90.         FAIL    "skip: distance to large"
  91.     ENDC
  92.     ENDC
  93.     ENDM
  94. ****************************************************************
  95. ***** write \1 times opcode NOP starting at address \2
  96. nops    MACRO
  97.     IFNE    NARG-2
  98.         FAIL    arguments "nops"
  99.     ENDC
  100.         movem.l    d0/a0,-(a7)
  101.         IFGT \1-127
  102.             move.w    #\1-1,d0
  103.         ELSE
  104.             moveq    #\1-1,d0
  105.         ENDC
  106.         lea    \2,a0
  107. .lp\@        move.w    #$4e71,(a0)+
  108.         dbf    d0,.lp\@
  109.         movem.l    (a7)+,d0/a0
  110.     ENDM
  111.  
  112. ****************************************************************
  113. ***** write opcode JMP \2 to address \1
  114. patch    MACRO
  115.     IFNE    NARG-2
  116.         FAIL    arguments "patch"
  117.     ENDC
  118.         move.w    #$4ef9,\1
  119.         pea    \2
  120.         move.l    (a7)+,2+\1
  121.     ENDM
  122.  
  123. ****************************************************************
  124. ***** write opcode JSR \2 to address \1
  125. patchs    MACRO
  126.     IFNE    NARG-2
  127.         FAIL    arguments "patchs"
  128.     ENDC
  129.         move.w    #$4eb9,\1
  130.         pea    \2
  131.         move.l    (a7)+,2+\1
  132.     ENDM
  133.  
  134. ****************************************************************
  135. ***** wait that blitter has finished his job
  136. ***** (this is adapted from graphics.WaitBlit, see autodocs for
  137. *****  hardware bugs and possible problems ...)
  138. ***** if \1 is given it must be an address register containing _custom
  139. BLITWAIT MACRO
  140.     IFEQ    NARG-1
  141.         tst.b    (dmaconr,\1)
  142. .waitb\@    tst.b    (_ciaa)        ;this avoids blitter slow down
  143.         tst.b    (_ciaa)
  144.         btst    #DMAB_BLTDONE-8,(dmaconr,\1)
  145.         bne.b    .waitb\@
  146.         tst.b    (dmaconr,\1)
  147.     ELSE
  148.         tst.b    (_custom+dmaconr)
  149. .waitb\@    tst.b    (_ciaa)        ;this avoids blitter slow down
  150.         tst.b    (_ciaa)
  151.         btst    #DMAB_BLTDONE-8,(_custom+dmaconr)
  152.         bne.b    .waitb\@
  153.         tst.b    (_custom+dmaconr)
  154.     ENDC
  155.     ENDM
  156.  
  157. ****************************************************************
  158. ***** wait of vertical blank
  159. ***** if \1 is given it must be an address register containing _custom
  160. waitvb    MACRO
  161.     IFEQ    NARG-1
  162. .1\@        btst    #0,(vposr+1,\1)
  163.         beq    .1\@
  164. .2\@        btst    #0,(vposr+1,\1)
  165.         bne    .2\@
  166.     ELSE
  167. .1\@        btst    #0,(_custom+vposr+1)
  168.         beq    .1\@
  169. .2\@        btst    #0,(_custom+vposr+1)
  170.         bne    .2\@
  171.     ENDC
  172.     ENDM
  173.  
  174. ****************************************************************
  175. ***** wait for pressing any button
  176. ***** if \1 is given it must be an address register containing _custom
  177. waitbutton    MACRO
  178.     IFEQ    NARG
  179.         move.l    a0,-(a7)
  180.         lea    (_custom),a0
  181. .down\@        bsr    .wait\@
  182.         btst    #CIAB_GAMEPORT0,(ciapra+_ciaa)        ;LMB
  183.         beq    .up\@
  184.         btst    #POTGOB_DATLY-8,(potinp,a0)        ;RMB
  185.         beq    .up\@
  186.         btst    #CIAB_GAMEPORT1,(ciapra+_ciaa)        ;FIRE
  187.         bne    .down\@
  188. .up\@        bsr    .wait\@                    ;entprellen
  189.         btst    #CIAB_GAMEPORT0,(ciapra+_ciaa)        ;LMB
  190.         beq    .up\@
  191.         btst    #POTGOB_DATLY-8,(potinp,a0)        ;RMB
  192.         beq    .up\@
  193.         btst    #CIAB_GAMEPORT1,(ciapra+_ciaa)        ;FIRE
  194.         beq    .up\@
  195.         bsr    .wait\@                    ;entprellen
  196.         bra    .done\@
  197. .wait\@        waitvb    a0
  198.         rts
  199. .done\@        move.l    (a7)+,a0
  200.     ELSE
  201.     IFEQ    NARG-1
  202. .down\@        bsr    .wait\@
  203.         btst    #CIAB_GAMEPORT0,(ciapra+_ciaa)        ;LMB
  204.         beq    .up\@
  205.         btst    #POTGOB_DATLY-8,(potinp,\1)        ;RMB
  206.         beq    .up\@
  207.         btst    #CIAB_GAMEPORT1,(ciapra+_ciaa)        ;FIRE
  208.         bne    .down\@
  209. .up\@        bsr    .wait\@                    ;entprellen
  210.         btst    #CIAB_GAMEPORT0,(ciapra+_ciaa)        ;LMB
  211.         beq    .up\@
  212.         btst    #POTGOB_DATLY-8,(potinp,\1)        ;RMB
  213.         beq    .up\@
  214.         btst    #CIAB_GAMEPORT1,(ciapra+_ciaa)        ;FIRE
  215.         beq    .up\@
  216.         bsr    .wait\@                    ;entprellen
  217.         bra    .done\@
  218. .wait\@        waitvb    \1
  219.         rts
  220. .done\@
  221.     ELSE
  222.         FAIL    arguments "waitbutton"
  223.     ENDC
  224.     ENDC
  225.     ENDM
  226.     
  227. waitbuttonup    MACRO
  228.     IFEQ    NARG
  229.         move.l    a0,-(a7)
  230.         lea    (_custom),a0
  231. .up\@        bsr    .wait\@                    ;entprellen
  232.         btst    #CIAB_GAMEPORT0,(ciapra+_ciaa)        ;LMB
  233.         beq    .up\@
  234.         btst    #POTGOB_DATLY-8,(potinp,a0)        ;RMB
  235.         beq    .up\@
  236.         btst    #CIAB_GAMEPORT1,(ciapra+_ciaa)        ;FIRE
  237.         beq    .up\@
  238.         bsr    .wait\@                    ;entprellen
  239.         bra    .done\@
  240. .wait\@        waitvb    a0
  241.         rts
  242. .done\@        move.l    (a7)+,a0
  243.     ELSE
  244.     IFEQ    NARG-1
  245. .up\@        waitvb    \1                    ;entprellen
  246.         btst    #CIAB_GAMEPORT0,(ciapra+_ciaa)        ;LMB
  247.         beq    .up\@
  248.         btst    #POTGOB_DATLY-8,(potinp,\1)        ;RMB
  249.         beq    .up\@
  250.         btst    #CIAB_GAMEPORT1,(ciapra+_ciaa)        ;FIRE
  251.         beq    .up\@
  252.         waitvb    \1                    ;entprellen
  253.     ELSE
  254.         FAIL    arguments "waitbuttonup"
  255.     ENDC
  256.     ENDC
  257.     ENDM
  258.  
  259. ****************************************************************
  260. ***** flash the screen and wait for LMB
  261. blitz        MACRO
  262.         move    #$1200,bplcon0+_custom
  263.     ;    move    #DMAF_SETCLR|DMAF_RASTER,dmacon+_custom
  264.         move.l    d0,-(a7)
  265. .lpbl\@        move.w    d0,$dff180
  266.         subq.w    #1,d0
  267.         btst    #6,$bfe001
  268.         bne    .lpbl\@
  269.         waitvb            ;entprellen
  270. .lp2bl\@    move.w    d0,$dff180
  271.         subq.w    #1,d0
  272.         btst    #6,$bfe001
  273.         beq    .lp2bl\@
  274.         clr.w    $dff180
  275.         move.l    (a7)+,d0
  276.         ENDM
  277.  
  278. ****************************************************************
  279. ***** install Vertical-Blank-Interrupt which quits on LMB pressed
  280. QUITVBI        MACRO
  281.         move.l    a0,-(a7)
  282.         lea    .vbi,a0
  283.         move.l    a0,$6c
  284.         bra    .g
  285. .vbi        btst    #6,$bfe001
  286.         beq    .vbi+1        ;create "address error"
  287.         move.w    #INTF_VERTB,_custom+intreq
  288.         rte
  289. .g        move.w    #INTF_SETCLR|INTF_INTEN|INTF_VERTB,_custom+intena
  290.         move.w    #INTF_VERTB,_custom+intreq
  291.         move.l    (a7)+,a0
  292.     ENDM
  293.  
  294. ****************************************************************
  295. ***** set all registers to zero
  296. resetregs    MACRO
  297.         moveq    #0,d0
  298.         moveq    #0,d1
  299.         moveq    #0,d2
  300.         moveq    #0,d3
  301.         moveq    #0,d4
  302.         moveq    #0,d5
  303.         moveq    #0,d6
  304.         moveq    #0,d7
  305.         sub.l    a0,a0
  306.         sub.l    a1,a1
  307.         sub.l    a2,a2
  308.         sub.l    a3,a3
  309.         sub.l    a4,a4
  310.         sub.l    a5,a5
  311.         sub.l    a6,a6
  312.     ENDM
  313. ;=============================================================================
  314. ;    return-values for termination (resload_Abort)
  315. ;=============================================================================
  316.  
  317. TDREASON_OK        = -1    ;normal termination
  318. TDREASON_DOSREAD    = 1    ;error with resload_ReadFile
  319.                 ;primary   = dos errorcode
  320.                 ;secondary = file name
  321. TDREASON_DOSWRITE    = 2    ;error with resload_SaveFile/resload_SaveFileOffset
  322.                 ;primary   = dos errorcode
  323.                 ;secondary = file name
  324. TDREASON_DEBUG        = 5    ;make coredump and quit
  325.                 ;primary   = PC
  326.                 ;secondary = SR
  327. TDREASON_DOSLIST    = 6    ;error with resload_ListFiles
  328.                 ;primary   = dos errorcode
  329.                 ;secondary = directory name
  330. TDREASON_DISKLOAD    = 7    ;error with resload_DiskLoad
  331.                 ;primary   = dos errorcode
  332.                 ;secondary = disk number
  333. TDREASON_DISKLOADDEV    = 8    ;error with resload_DiskLoadDev
  334.                 ;primary   = trackdisk errorcode
  335. TDREASON_WRONGVER    = 9    ;an version check (e.g. crc16) has detected an
  336.                 ;unsupported version of data files
  337. TDREASON_OSEMUFAIL    = 10    ;error in the OS emulation module
  338.                 ;primary   = subsystem (e.g. "exec.library")
  339.                 ;secondary = error number (e.g. #_LVOAllocMem)
  340. ; version 7
  341. TDREASON_REQ68020    = 11    ;Slave/installed program requires 68020
  342. TDREASON_REQAGA        = 12    ;Slave/installed program requires AGA Chip Set
  343. TDREASON_MUSTNTSC    = 13    ;installed program needs NTSC to run
  344. TDREASON_MUSTPAL    = 14    ;installed program